package me.magicall.test.db.spring.dao2;

import javax.sql.DataSource;

import org.springframework.context.support.ClassPathXmlApplicationContext;
import org.springframework.jdbc.core.namedparam.NamedParameterJdbcOperations;
import org.springframework.jdbc.core.namedparam.NamedParameterJdbcTemplate;
import org.springframework.jdbc.core.simple.SimpleJdbcTemplate;

public class U {

//	static boolean methodHasSql(final Method method) {
//		return getSql(method) != null;
//	}
//
//	static String getSql(final Method method) {
////		final Annotation[] annotations = method.getAnnotations();
////		for (final Annotation annotation : annotations) {
////			if (annotation.getClass().isAnnotationPresent(IsSql.class)) {
////				return annotation.values();
////			}
////		}
//		return null;
//	}

	public static NamedParameterJdbcOperations getNamedJdbc() {
		final ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext("applicationContext.xml");
		final DataSource dataSource = (DataSource) context.getBean("dataSource");
		return new NamedParameterJdbcTemplate(dataSource);
	}

	public static SimpleJdbcTemplate getSimpleJdbcTemplate() {
		final ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext("applicationContext.xml");
		return (SimpleJdbcTemplate) context.getBean("simpleJdbcTemplate");
	}
}
